package com.glink.mydemo;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import android.widget.FrameLayout;

import com.baize.glinkad.bean.ADInfo;
import com.baize.glinkad.bean.ADType;
import com.baize.glinkad.bean.ads.BannerAD;
import com.baize.glinkad.bean.listener.BannerListener;
import com.baize.glinkad.manager.GLinkADManager;
import com.baize.glinkad.utils.ADLogHelper;


public class BannerActivity extends Activity {
    public FrameLayout bannerLayout;
    private Button show_banner;
    private BannerAD banner;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_banner);

        bannerLayout=(FrameLayout) findViewById(R.id.bannerLayout);
        show_banner=(Button)findViewById(R.id.show_banner);

        ADInfo adInfo = new ADInfo();
        adInfo.adType = ADType.BANNER;
        adInfo.adView = bannerLayout;
        adInfo.adHeigth=100;
        banner = new BannerAD(this,adInfo,"Banner");

        banner.setBannerListener(new BannerListener() {
            @Override
            public void onReady() {

            }

            @Override
            public void onFail(String code, String msg) {
                ADLogHelper.info("onFail： code: "+code+"   msg:"+msg);
            }

            @Override
            public void onClicked() {
                ADLogHelper.info("onClicked");
            }

            @Override
            public void onShow() {
                ADLogHelper.info("onShow");
            }

            @Override
            public void onClose() {
                ADLogHelper.info("onClose");
            }


        });
      show_banner.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //加载广告
                banner.load();
            }
        });
    }

    @Override
    protected void onDestroy() {
        GLinkADManager.onDestory(this);
        super.onDestroy();

    }

    @Override
    protected void onResume() {
        GLinkADManager.onResume(this);
        super.onResume();

    }

    @Override
    protected void onPause() {
        GLinkADManager.onPause(this);
        super.onPause();

    }
}
